﻿<cfsilent>
	<cfscript>
		
		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");
		
		schoolArray = arrayNew(1);
		rs_school = queryNew("sch_code");
		if ( event.isArgDefined('Keywords') AND len(event.getArg('Keywords')) ) {
			
			sql = "SELECT a.sch_code, 
						  a.sch_name
					FROM t_dict_school a  
					WHERE 
						a.sch_code LIKE :keyword 
						OR 
						a.sch_name LIKE :keyword 
					ORDER BY a.sch_name ASC";
			queryObj = new Query( datasource=application.dnsSlave,maxRows=18 ); 
			queryObj.addParam( name="keyword", value=event.getArg('Keywords')&'%', cfsqltype="cf_sql_varchar" );
			rs_school= queryObj.execute( sql=sql ).getResult();
			
			for( a=1; a LTE rs_school.recordCount; a++ ){
				arrayAppend(schoolArray,[rs_school["sch_code"][a],rs_school["sch_name"][a]]);
			}
			
		}
		
	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:schoolArray, stringNumbers:true)#</cfoutput>